package nus.edu.sg.main;

import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.*;

import nus.edu.sg.db.DBDashboardCmd;
import nus.edu.sg.object.SampleTimeConfiguration;

public class DBDashboardImpl implements IDBDashboard {
	
	DBDashboardCmd dbDashboardCmd=new DBDashboardCmd();

	@Override
	public BigDecimal getOverallPerformance(String parameterId,
			Timestamp starTime, Timestamp endTime) throws Exception {
		return 	dbDashboardCmd.getStatOverall(parameterId,starTime, endTime);

	}

	@Override
	public ArrayList<String> getAdvices(String parameterId, Timestamp c)
			throws Exception {
		// TODO Auto-generated method stub
		return dbDashboardCmd.getAdvices(parameterId, c);
	}

	@Override
	public HashMap<Long, String> getPerformanceBreakdown(String parameterId,
			String level, Timestamp starTime, Timestamp endTime)
			throws Exception {
		return dbDashboardCmd.getStatLevel(parameterId, starTime, endTime,level);
		
	}

	@Override
	public void configureSampleTimes(int x, int y, int z) throws Exception {
		
		dbDashboardCmd.startSchdular(x*60, y*60, z*60);
		SampleTimeConfiguration.getInstance().setX(x);
		SampleTimeConfiguration.getInstance().setY(y);
		SampleTimeConfiguration.getInstance().setZ(z);

	}

	@Override
	public ArrayList <String[]> getSqlResult(String sqlQuery) throws Exception {
		return dbDashboardCmd.getSqlQueryResult(sqlQuery);
	}

	@Override
	public String getAwrReport(Timestamp startTime, Timestamp endTime)
			throws Exception {
		return dbDashboardCmd.getAwrReport(startTime, endTime);
	}

}
